package com.pzh.assignment.common.bean.vo;

import com.pzh.assignment.common.bean.GlobalConstant;
import com.pzh.assignment.entity.Grade;
import lombok.Data;

import java.time.format.DateTimeFormatter;


@Data
public class GradeVO {
    private Integer id;

    private Integer grade;

    private String createTime;

    private String updateTime;

    public static GradeVO valueOf(Grade grade) {
        GradeVO vo = new GradeVO();
        vo.setId(grade.getId());
        vo.setGrade(grade.getGrade());
        if (grade.getCreateTime() != null) {
            vo.setCreateTime(grade.getCreateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        if (grade.getUpdateTime() != null) {
            vo.setUpdateTime(grade.getUpdateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        return vo;
    }
}
